V2 APIs - Batch mint
To batch mint NFTs the following operations has to be done in a sequential order
Base URL:
https://api.0xmint.io
https://api.mintnft.today (Deprecated, Please don't use this in production)
1. Upload Assets
This route is to upload assets of NFTs to mint. The folowing set of rules are to be followed to upload assets.
The file name convention should be [number].[filetype], where the number starts with 0 to N. Eg: 0.png, 1.png, .... n.png
The preview images should also foloow the same convention.
The metadata file in CSV or JSON file. Please follow the sample file structure. (CSV, JSON)
Ensure each file is below 100MB
End point:
/v2/batch/uploadAssets
Request type : form-data
Request method : POST
| Parameters | Type | Description |
|---|---|---|
| Header x-api-key | string | API key from dashboard |
| Header x-auth-token | string | JWT token |
| wallet | text | The wallet address associated with the API key |
| sessionName | text | The session or project name |
| csv | file | The metadata file in CSV format |
| assets | file | The NFT files with supported formats |
| preview | file | The preivew files for each original assets |
Response
{
sessionID: "7fe11b9a-ae13-41c7-bd32-2b520cf4fd57"
}
It's receommneded to store this sessionID to do the further request.
2. Deploy and update contract
Collection creation or Deploy contract is a direct interaction with contract that should be called by the owner of the collection.
Contract ABI: Please copy the contract ABI from Etherscan(https://polygonscan.com/address/0x1aF7768737e41D227Fd0f6330Ed7B0ad846A8B73#code)
Contract Address: 0x1aF7768737e41D227Fd0f6330Ed7B0ad846A8B73
Example using web3.js
const CollectionCreationContract = web3.eth.Contract(contractABI, contractAddress);
const receipt = await CollectionCreationContract.methods.createCollection(
"0x2631e5e8717fAeaD0EBa72fEd5694aD1Fa0d3581", //Collection owner address
"Sesion ID", //Session ID - Session ID returned from the upload asset request
"My Collection name", //Collection name
"My Collection symbol", //Collection symbol
).send({from: collectionOwnerAddress});
Once the contract is deployed using the following route to update the contract details
End point:
/v2/batch/updateCollectionData
Request type : application/json
Request method : POST
| Parameters | Type | Description |
|---|---|---|
| Header x-api-key | string | API key from dashboard |
| Header x-auth-token | string | JWT token |
| wallet | string | The wallet address associated with the API key |
| sessionID | string | The session ID |
Response
{
"isCreated": true,
"staus": "ok",
"message": "Contract Address for the session updated"
}
3. Upload to IPFS
Initiate asset upload to IPFS.
End point:
/v2/batch/ipfs
Request type : application/json
Request method : POST
| Parameters | Type | Description |
|---|---|---|
| Header x-api-key | string | API key from dashboard |
| Header x-auth-token | string | JWT token |
| wallet | string | The wallet address associated with the API key |
| sessionID | string | The session ID |
Response
{
"message": "Upload to IPFS initiated! Please hit checkStatus route for the updates!"
}
4. Get status
Get the status of all the steps invloved in batch minting
End point:
/v2/batch/checkStatus/${sessionID}
Request method : GET
| Parameters | Type | Description |
|---|---|---|
| Header x-api-key | string | API key from dashboard |
| Header x-auth-token | string | JWT token |
Response
{
"s3": "CONFIRMED",
"ipfs": "PENDING",
"gas": "NULL",
"mint": "NULL",
"refund": "NULL"
}
5. Deposit Gas
Like collection creation, gas deposit is also a direct contract interaction to be done by calling a contract function.
To get the estimated gas fee to depsit the following route can be used.
End point:
/v2/batch/getEstimatedGas/${sessionID}
Request method : GET
| Parameters | Type | Description |
|---|---|---|
| Header x-api-key | string | API key from dashboard |
| Header x-auth-token | string | JWT token |
Response
{
"estimatedGas": "11815759403822203804"
}
The return value is the gas fee which is in wei unit. Exactly, this value should be deposited to the contract.
Contract ABI: Please copy the contract ABI from Etherscan(https://polygonscan.com/address/0xf0dd1d55c3380d0a4e66f06f2af70dc9adb09365#code)
Contract Address: 0xb3E5FA3F9e1DF2b8274c9c8568716d7A23066C0f
const GasWalletContract = web3.eth.Contract(contractABI, contractAddress);
const receipt = await GasWalletContract.methods.depositGas(SessionID).send{from: collectionOnwer, value: estimagtedGas};
6. Mint
Intiate the batch mint process
End point:
/v2/batch/mint
Request type : application/json
Request method : POST
| Parameters | Type | Description |
|---|---|---|
| Header x-api-key | string | API key from dashboard |
| Header x-auth-token | string | JWT token |
| wallet | string | The wallet address associated with the API key |
| sessionID | string | The session ID |
| network | string | mainnet or mumbai |
Response
{
"message": "Transaction initiated!"
}
7. Get Mint Details
Get all the batch mint details done with a particular wallet
End point:
/v2/batch/collection/${wallet}
Request type : application/json
Request method : POST
| Parameters | Type | Description |
|---|---|---|
| Header x-api-key | string | API key from dashboard |
| Header x-auth-token | string | JWT token |
Response
[
{
"_id": "63721f6def9c1c9f8aa2375c",
"wallet": "0x2631e5e8717fAeaD0EBa72fEd5694aD1Fa0d3581",
"sessionID": "3a30c537-6177-4f97-9bcf-4eb6932c71d1",
"network": "mainnet",
"name": "Batchmint test",
"transactionHashes": [
{
"hash": "0xa74a2533aa7477eca7d9517bc9d5e5ee76ceba03e9f1ae20359d85b6d9ee7668",
"status": "CONFIRMED",
"batchNo": 0,
"gasConsumed": "25858666880427960",
"from": 0,
"to": 4
}
],
"filesCount": 5,
"gasPrice": "36319545107",
"estimatedGas": "727294459783171946",
"contractAddress": "0xBC4B63E8e1E2f89Ed57f8B400283f04597DC2ABc",
"depositedAmount": "0",
"totalGasUsed": "25858666880427960",
"refundAmount": "701435792902743986",
"status": {
"s3": "CONFIRMED",
"ipfs": "CONFIRMED",
"gas": "INSUFFICIENT",
"mint": "CONFIRMED",
"refund": "CONFIRMED"
},
"createdAt": "2022-11-14T10:58:53.038Z",
"updatedAt": "2022-11-15T10:57:10.419Z",
"__v": 0,
"hash": "{\"assetHash\":\"ipfs://bafybeic6xv5ri5tpipnxrztmzy2qrffq5vvuv5pirpeucrhwryw5evdyfa/assets\",\"previewHash\":\"ipfs://bafybeifgjbp7cyu36tylxlpx2bsd67tx2fzdlvyq5uewyl2v5pdnx44a4q/preview\",\"metadataHash\":\"ipfs://bafybeierbao4yi3eoeli6zpmo2y2g3es6m4fb6egyl2lfybllci5k725l4/metadata\"}",
"refundHash": "0x0e96dccc1aceeb5788a96adffa2e04fb75239d6ec2510aac958ccf0028e65705"
}
]